/**
 * @fileoverview Renderer Template.
 *
 * @license Copyright 2015 The Coding with Chrome Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @author mbordihn@google.com (Markus Bordihn)
 */

{namespace cwc.soy.Renderer autoescape="strict"}

/**
 * Object template.
 */
{template .objectTemplate}
  {@param data_url: string}
  {@param type: string}
  {@param width: number}
  {@param height: number}

  <object data="{$data_url}" type="{$type}" width="{$width}" height="{$height}"></object>
{/template}


/**
 * HTML base template.
 */
{template .html}
  {@param? body: string}
  {@param? head: string}
  {@param? css: string}
  {@param? js: string}
  {@param? style: string}
  {@param? canvas: string}

  <!DOCTYPE html>{\n}
  <html>{\n}
    <head>{\n}
      <style>
        * {lb} margin:0; padding:0; {rb}
        html, body {lb} width:100%; height:100%; overflow: hidden;{rb}
        canvas {lb} display:block; {rb}
        {if $style}{$style}{\n}{/if}
      </style>{\n}
      {if $css}
        {call .css}
          {param content: $css /}
        {/call}
      {/if}
      {if $head}{$head}{\n}{/if}
    </head>{\n}
    <body>{\n}
      {if $canvas}
        <canvas id="{$canvas}"></canvas>{\n}
      {/if}
      {if $body}{$body}{\n}{/if}
      {if $js}
        {call .javaScriptContent}
          {param content: $js /}
        {/call}
      {/if}
    </body>{\n}
  </html>{\n}
{/template}


/**
 * HTML base template.
 */
{template .htmlGrid}
  {@param body: string}
  {@param? head: string}
  {@param? css: string}
  {@param? js: string}

  {call .html data="all"}
    {param style kind="css"}
      body {lb}
        background-size: 25px 25px;
        background-image: linear-gradient(to right, #eee 1px, transparent 1px),
          linear-gradient(to bottom, #eee 1px, transparent 1px);
      {rb}
    {/param}
  {/call}

{/template}


/**
 * HTML messenger template.
 */
{template .htmlMessenger}
  {@param body: string}
  {@param head: string}

  {call .html data="all"}
    {param body kind="html"}
      <div id="messenger"></div>
      {$body}
    {/param}
  {/call}

{/template}



/**
 * CSS tag.
 */
{template .css}
  {@param content: string}
  {@param? url: string}

  {if $url}
    <link rel="stylesheet" href="{$url}">{\n}
  {/if}
  {if $content}
    <style>{\n}{$content}{\n}</style>{\n}
  {/if}
{/template}


/**
 * JavaScript content.
 */
{template .javaScriptContent}
  {@param content: string}

  {if $content}
    <script>{\n}{$content}{\n}</script>{\n}
  {/if}
{/template}


/**
 * JavaScript url.
 */
{template .javaScriptUrl}
  {@param url: string}
  {@param? filename: string}

    <script src="{$url}"{if $filename} data-filename="{$filename}"{/if}></script>
  {\n}
{/template}


/**
 * JavaScript data url.
 */
{template .javaScriptDataUrl}
  {@param data: string}
  {@param encoding: string}
  {@param? filename: string}

    <script src="data:text/javascript;{$encoding},{$data}"{if $filename} data-filename="{$filename}"{/if}></script>
  {\n}
{/template}


/**
 * Style Sheet url.
 */
{template .styleSheetUrl}
  {@param url: string}
  {@param? filename: string}

    <link rel="stylesheet" type="text/css" href="{$url}"{if $filename} data-filename="{$filename}"{/if}>
  {\n}
{/template}


/**
 * Style Sheet data url.
 */
{template .styleSheetDataUrl}
  {@param data: string}
  {@param encoding: string}
  {@param? filename: string}

    <link rel="stylesheet" type="text/css" href="data:text/css;{$encoding},{$data}"{if $filename} data-filename="{$filename}"{/if}>
  {\n}
{/template}
